<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Treinos</title>
    </h:head>
    <h:body> 
        <ui:composition template="./face-professor.xhtml">
            <ui:define name="login"><h:outputText id="lblBemVindo" value="#{login.professor.nome}" /></ui:define>
            <ui:define name="content">
                <h:form>
                    <p:panel header="Novo Treino">                
                        <h:panelGrid columns="2" >
                            <h:outputLabel id="lblCodigo" value="Código:"/>
                            <h:inputText id="txtCodigo" value="#{treinoImplements.treino.id}" disabled="true">0</h:inputText>                    
                            <h:outputLabel id="lblAluno" value="Aluno:"/>
                            <h:selectOneMenu id="ddlAlunos" value="#{treinoImplements.aluno.id}" immediate="true" onchange="submit();" valueChangeListener="#{treinoImplements.pesquisaPorAluno}">
                                <f:selectItem itemLabel="--Selecione--" itemValue="0"/>
                                <f:selectItems value="#{treinoImplements.listaAluno}" var="al"
                                               itemLabel="#{al.nome}" itemValue="#{al.id}" />
                            </h:selectOneMenu>
                            <h:outputLabel id="lblTipoTreino" value="Tipo Treino Atual:"/>
                            <h:inputText id="txtTipoTreinoNome" value="#{treinoImplements.tipoTreino.nome}" disabled="true">Selecione Abaixo</h:inputText>
                            <h:outputLabel id="lblTipoTreinoAlterar" value="Alterar Tipo Treino:"/>            
                            <h:selectOneMenu id="ddlTipoTreinos" value="#{treinoImplements.idTipoTreinoTemp}">
                                <f:selectItem itemLabel="--Selecione--" itemValue="0"/>
                                <f:selectItems value="#{treinoImplements.listaTipoTreino}" var="tr"
                                               itemLabel="#{tr.nome}" itemValue="#{tr.id}"/>
                            </h:selectOneMenu>                            
                            <h:outputLabel id="lblDataInicio" value="Data de In&iacute;cio: " />
                            <p:calendar value="#{treinoImplements.treino.dataInicio}" disabled="true" />
                            <h:outputLabel id="lblDataAtualizacao" value="Data de Atualiza&ccedil;&atilde;o: " />
                            <p:calendar value="#{treinoImplements.treino.dataAtualizacao}" disabled="true" />
                            <h:outputLabel id="lblDataExpira" value="Data que Expira: " />
                            <p:calendar value="#{treinoImplements.treino.dataExpira}" disabled="true"/>
                            <h:outputLabel id="lblDataExpiraTemp" value="Alterar Data que Expira:"/>
                            <p:calendar value="#{treinoImplements.dataExpiraTemp}" />
                            <h:outputLabel id="lblSalvar" value="Clique para salvar:"/>
                            <h:commandButton action="#{treinoImplements.salvar}" value="Salvar"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>        
                <h:form prependId="false" >
                    <p:panel header="Exerc&iacute;cios">
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="Exerc&iacute;cio:" for="ddlExercicios"/>
                            <h:selectOneMenu id="ddlExercicios" value="#{treinoImplements.idExercicioTemp}">
                                <f:selectItem itemLabel="--Selecione--" itemValue="0"/>
                                <f:selectItems value="#{treinoImplements.listaExercicio}" var="al"
                                               itemLabel="#{al.nome}" itemValue="#{al.id}"/>
                            </h:selectOneMenu>
                            <p:commandButton value="Adicionar" action="#{treinoImplements.adicionaExercicio}" update="dttExercicios"/>
                            <p:ajaxStatus >
                                <f:facet name="start">
                                    <h:graphicImage value=""/>                            
                                </f:facet>
                                <f:facet name="complete">
                                    <h:outputText value=""/>
                                </f:facet>
                            </p:ajaxStatus>
                        </h:panelGrid>
                    </p:panel>
                    <p:dataTable id="dttExercicios" value="#{treinoImplements.exerciciosSelecionados}" var="ex">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Código do Exerc&iacute;cio"/>
                            </f:facet>
                            <h:outputText value="#{ex.id}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Nome do Exerc&iacute;cio"/>
                            </f:facet>
                            <h:outputText value="#{ex.nome}" />
                        </p:column>
                    </p:dataTable>
                </h:form>        

            </ui:define>

        </ui:composition>
    </h:body>
</html>

